package com.example.teststatisticesinterface.db;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.oppo.statistics.helper.DatabaseHelper;

public class Dbhelper {
	private DatabaseHelper dbHelper;

	public static final String TABLE_APP_LOG="table_app_log";
	public static final String TABLE_ACTIONS="actions";
	public static final String TABLE_ACT_LOCATION="act_location";
	public static final String TABLE_APP_START="app_start";
	public static final String TABLE_DOWNLOAD="download";
	public static final String TABLE_SHARE="share";
	public static final String TABLE_SPECIAL_CLICK="special_click";
	public static final String TABLE_TABLE_PAGE_VISIT="table_page_visit";
	
	public Dbhelper(Context cx) {
		dbHelper = new DatabaseHelper(cx);
	}
	
	public static Cursor loadAllFromTable(Context cx,String table){
		SQLiteDatabase db=DatabaseHelper.getSQLiteDatabase(cx);
		Cursor cursor=db.query(table, null, null, null, null, null, null);
		return cursor;
	}

	public  static int queryTableCount(Context cx,String table){
		SQLiteDatabase sqLiteDatabase = DatabaseHelper.getSQLiteDatabase(cx);
		String sql = " select count (*) from "+table+" ";
		Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
		int count=cursor.getInt(0);
		return count;
	}
}
